# Maintainer: Fabian Bornschein <fabiscafe@archlinux.org>

pkgname=loupe
pkgver=45.1
pkgrel=1
pkgdesc="A simple image viewer for GNOME"
arch=(loong64 x86_64)
url="https://gitlab.gnome.org/GNOME/loupe"
license=('GPL')
groups=('gnome')
depends=(
  cairo
  glib2
  glycin
  graphene
  gtk4
  hicolor-icon-theme
  lcms2
  libadwaita
  libgweather-4
)
makedepends=(
  git
  itstool
  meson
  rust
)
_commit=23153056aeb6b0afbacec2e6fb2c6022d7a6e9d2 # tags/45.1^0
source=("git+https://gitlab.gnome.org/GNOME/loupe.git#commit=$_commit")
sha256sums=('SKIP')

# Use LTO
export CARGO_PROFILE_RELEASE_LTO=true CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1

# Use debug
export CARGO_PROFILE_RELEASE_DEBUG=2

pkgver() {
  cd $pkgname
  git describe --tags | sed -r 's/_/./;s/\.([a-z])/\1/;s/([a-z])\./\1/;s/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd $pkgname
}

build() {
  arch-meson $pkgname build
  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs
}

package() {
  meson install -C build --destdir "$pkgdir" --no-rebuild
}
